<?xml version="1.0" encoding="UTF-8" ?>
<%@page import="java.util.Iterator"%>
<%@page import="javax.servlet.jsp.jstl.fmt.LocalizationContext"%>
<%@page import="java.util.ResourceBundle"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Set"%>
<%@page import="org.jakim.entity.*"%>
<%@page import="org.jakim.utils.*"%>
<%@page import="org.apache.taglibs.standard.tlv.JstlCoreTLV"%>
<%@page import="org.apache.taglibs.standard.tlv.JstlFmtTLV"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<fmt:setLocale value="en" />
<fmt:setBundle basename="org.jakim.messages.messages" var="msg" scope="session" />
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
<link href="../styles/main.css" rel="stylesheet" type="text/css" />
<link href="../styles/wizard.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
</head>
<body>
<% 
	HttpSession httpSession = request.getSession();
	
	PersonalInforamation personalInfo = null;
	PersonalSkill personalSkills = null;
	List<WorkExperience> listWorkExperience = null;
	List<Education> listEducationAndSkills = null;
	List<Language> listLanguage = null;
	String motherLanguage = null;
	
	Object objPersonalInfo = httpSession.getAttribute("attrPersonalInfo");
	if (objPersonalInfo != null && objPersonalInfo instanceof PersonalInforamation){
		personalInfo = (PersonalInforamation) objPersonalInfo;
	}
	
	Object objPersonalSkills = httpSession.getAttribute("attrPersonalSkills");
	if (objPersonalSkills != null && objPersonalSkills instanceof PersonalSkill){
				personalSkills = (PersonalSkill) objPersonalSkills;
	}
	
	Object objWrokExperience = httpSession.getAttribute("attrWrokExperience");
	if (objWrokExperience != null && objWrokExperience instanceof List<?>){
		listWorkExperience = (List<WorkExperience>) objWrokExperience;
	}
	
	Object objEducationAndSkills = httpSession.getAttribute("attrEducationAndSkills");
	if (objEducationAndSkills != null && objEducationAndSkills instanceof List<?>){
			listEducationAndSkills = (List<Education>) objEducationAndSkills;
	}
	
	Object objLanguage = httpSession.getAttribute("attrLanguages");
	if(objLanguage != null && objLanguage instanceof List<?>){
		listLanguage = (List<Language>) objLanguage;
	}
	
%>

	<div>
		<header>
			<h1>
				<fmt:message key="ENDWIZARD.HEADER" />
			</h1>
	
			<p>
				<fmt:message key="ENDWIZARD.SUMMARY" />
			</p>
		</header>
		<section id="generatedCV">
			<section id="personalInfo">
				<h2>
					<fmt:message key="ENDWIZARD.FINALCV.PERSONALINFO" />
				</h2>
				<ol>
					<li><%=personalInfo.getUserName() + " " + personalInfo.getUserSirName()%></li>
					<li><%=personalInfo.getUserNationality()%></li>
					<li><%=personalInfo.getUserAddress().htmlFormatUserAddress()%></li>
					<li><%=personalInfo.getPhoneNumber()%></li>
					<li><%=personalInfo.getUserEmail()%></li>
					<li><%=personalInfo.getUserBirthDay() %>
						<fmt:message key="ENDWIZARD.FINALCV.PERSONALINFO.NATION" />
						<%=personalInfo.getUserNationality()%>
					</li>
				</ol>
			</section>
			
			<section id="wantedJob">
				<h2>
					<fmt:message key="ENDWIZARD.FINALCV.WANTEDJOB" />
				</h2>
				<ol>
					<li>Must be complete</li>
				</ol>
			</section>
			
			<section id="workExperience">
				<h2>
					<fmt:message key="ENDWIZARD.FINALCV.WORKEXPERIENCE" />
				</h2>
				<%
					Iterator<WorkExperience> jobIterator = listWorkExperience.iterator();
					while(jobIterator.hasNext()){
						WorkExperience job = jobIterator.next();
				%>
				<h3>
					<%=job.getHTMLDates()%>
				</h3>
				<ol>
					<li><%=job.getWorkOccupation() %></li>
					<li><%=job.getHtmlEmployerSpec() %></li>
					<li><%=job.getWorkMainActivities() %></li>
				</ol>	
				<%
					}
				%>
			</section>
			
			<section id="education">
				<h2>
					<fmt:message key="ENDWIZARD.FINALCV.EDUCATION" />
				</h2>
				<%
					Iterator<Education> educationIterator = listEducationAndSkills.iterator();
					while(educationIterator.hasNext()){
						Education education = educationIterator.next();
				%>
				<h3>
					<%=education.getHTMLDates()%>
				</h3>
				<ol>
					<li><%=education.getEducationClassificationLevel() + " " +education.getEducationQualificationTitle()%></li>
					<li><%=education.getEducationOrganisationName()%></li>
					<li><%=education.getEducationOrganisationType()%></li>
					<li><%=education.getEducationCity() + "" + education.getEducationCountry()%></li>
				</ol>	
				<%
					}
				%>
			</section>
			
			<section id="education">
				<h2>
					<fmt:message key="ENDWIZARD.FINALCV.EDUCATION" />
				</h2>
				<ol>
					<li><%=personalSkills.getMotherLanguage() %></li>
					<li><fmt:message key="ENDWIZARD.FINALCV.OTHERLANGUAGES" />
					<%
						Set<Language> setLanguages = personalSkills.getOtherLanguages();
						System.out.println(setLanguages.size());
						Iterator<Language> otherLanguagesIterator = setLanguages.iterator();
						
						Language language = null;
						while(otherLanguagesIterator.hasNext()){
							language = otherLanguagesIterator.next();
							%>
							<section>
								<div><%=language.getLanguageName() %></div>
								<section>
									<div><%=language.getLanguageListening() %></div>
									<div><%=language.getLanguageReading() %></div>
									<div><%=language.getLanguageWriting() %></div>
									<div><%=language.getLanguageProduction() %></div>
								</section>
							</section>
							<%
						}
					%>
					</li>
					<li><%=personalSkills.getSkillComputer()%></li>
					<li><%=personalSkills.getSkillOranisational()%></li>
					<li><%=personalSkills.getSkillArtistic()%></li>
					<li><%=personalSkills.getSkillTechnical()%></li>
					<li><%=personalSkills.getSkillSocial()%></li>
				</ol>	
			</section>
		</section>
	</div>

</body>
</html>
